package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.fiat_deal.bean.DealTeamBean;
import com.hxd.otc.module.fiat_deal.model.DealModel;
import com.hxd.otc.module.my.bean.NoSenseBean;
import com.hxd.otc.module.my.contract.NoSenseContract;
import com.hxd.otc.module.my.model.NoSenseModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.ArrayList;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面}
 */
public class NoSensePresenter extends BasePresenter<NoSenseContract.View> implements NoSenseContract.Presenter {

    public NoSenseModel noSenseModel;
    public DealModel dealModel;
    public String time;

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public NoSensePresenter(NoSenseContract.View view) {
        super(view);
        noSenseModel = NoSenseModel.getInstance();
        dealModel = new DealModel();
    }

    @Override
    public void start() {

    }


    @Override
    public void getCoinList() {
        dealModel.getCoinType(new BaseObserver<ArrayList<DealTeamBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ArrayList<DealTeamBean> dealTeamBeans) {
                if (dealTeamBeans.size() > 0) {
                    mView.setCoinList(dealTeamBeans);
                }
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
                doShowNoMore();
            }

        }, mView.<BaseBean<ArrayList<DealTeamBean>>>bindAutoDispose());
    }

    @Override
    public void doLoadData(boolean isRefresh, String... category) {
        noSenseModel.getNoSenseData(category[0], category[1],category[2], new BaseObserver<NoSenseBean>() {
            @Override
            public void onNext(String title, @NonNull NoSenseBean noSenseBean) {
                doSetAdapter(noSenseBean);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
                doShowNoMore();
            }

        }, mView.<BaseBean<NoSenseBean>>bindAutoDispose());

    }

    @Override
    public void doSetAdapter(NoSenseBean bean) {
        doShowNoMore();
        mView.onSetAdapter(bean);
    }


    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }


}
